<?php
/**
 * Date: 2021/8/5
 * Time: 10:43
 * 用户模型
 */
namespace App\Model;


use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;



class LogModel extends Model
{
    protected $table = 'log';




    /*
     * 后台获取日志
     * page 页数
     * limit 条数
     * date 日期
     */
    public static function getLogin(int $page,int $limit,String $date){
        $pagenNum=$page-1;

        if ($pagenNum != 0) {
            $pagenNum = $limit * $pagenNum;
        }


        $logData=LogModel::whereBetween('add_time',[strtotime($date),strtotime($date)+86399])->offset($pagenNum)->limit($limit)->orderBy('add_time','desc')->get()->each(function($item,$query){
            $item->add_time=date('Y-m-d H:i:s',$item->add_time);
        });

        $pageTotal=LogModel::whereBetween('add_time',[strtotime($date),strtotime($date)+86399])->count();
     


        $data['data']=$logData;
        $data['pageTotal']=$pageTotal;

        return $data;


    }


}